(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 9.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[      5016,        143]
NotebookOptionsPosition[      4657,        126]
NotebookOutlinePosition[      5008,        141]
CellTagsIndexPosition[      4965,        138]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[""], "Input",
 CellChangeTimes->{{3.601101734523904*^9, 3.6011017351759415`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"atan2", "[", 
   RowBox[{"a_", ",", "b_"}], "]"}], ":=", 
  RowBox[{"ArcTan", "[", 
   RowBox[{
    RowBox[{
     RowBox[{"(", 
      RowBox[{"a", "-", "b"}], ")"}], "[", 
     RowBox[{"[", "1", "]"}], "]"}], ",", 
    RowBox[{
     RowBox[{"(", 
      RowBox[{"a", "-", "b"}], ")"}], "[", 
     RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"angle", "[", 
    RowBox[{"p0_", ",", "p1_", ",", "p2_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{"atan2", "[", 
     RowBox[{"p2", ",", "p1"}], "]"}], "-", 
    RowBox[{"atan2", "[", 
     RowBox[{"p0", ",", "p1"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"correct", "[", "t_", "]"}], ":=", 
  RowBox[{"If", "[", 
   RowBox[{
    RowBox[{"t", ">", "0"}], ",", 
    RowBox[{"t", "-", "\[Pi]"}], ",", 
    RowBox[{"t", "+", "\[Pi]"}]}], "]"}]}], "\[IndentingNewLine]", 
 RowBox[{"DynamicModule", "[", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{
     RowBox[{"p0", "=", 
      RowBox[{"{", 
       RowBox[{"0", ",", "1"}], "}"}]}], ",", 
     RowBox[{"p1", "=", 
      RowBox[{"{", 
       RowBox[{"0.5", ",", "0.5"}], "}"}]}], ",", 
     RowBox[{"p2", "=", 
      RowBox[{"{", 
       RowBox[{"1", ",", "0"}], "}"}]}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"Graphics", "[", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"Locator", "[", 
         RowBox[{"Dynamic", "[", "p0", "]"}], "]"}], ",", 
        RowBox[{"Locator", "[", 
         RowBox[{"Dynamic", "[", "p1", "]"}], "]"}], ",", 
        RowBox[{"Locator", "[", 
         RowBox[{"Dynamic", "[", "p2", "]"}], "]"}]}], "}"}], "]"}], ",", 
     RowBox[{"Dynamic", "[", 
      RowBox[{"MatrixForm", "[", 
       RowBox[{"{", 
        RowBox[{"p0", ",", "p1", ",", "p2"}], "}"}], "]"}], "]"}], ",", 
     RowBox[{"Dynamic", "[", 
      RowBox[{"correct", "[", 
       RowBox[{"angle", "[", 
        RowBox[{"p0", ",", "p1", ",", "p2"}], "]"}], "]"}], "]"}]}], "}"}]}], 
  "]"}]}], "Input",
 CellChangeTimes->{{3.6011017712810063`*^9, 3.6011018040338793`*^9}, {
   3.601101834254608*^9, 3.601101839824927*^9}, {3.601101870077657*^9, 
   3.601101900653406*^9}, {3.6011019426228065`*^9, 3.6011019644370546`*^9}, {
   3.601101994470772*^9, 3.6011021092953396`*^9}, {3.601102148222566*^9, 
   3.6011022112691727`*^9}, {3.601102327108798*^9, 3.601102392059513*^9}, {
   3.6011024222842417`*^9, 3.6011024316077747`*^9}, {3.6011025035118876`*^9, 
   3.601102514201499*^9}, {3.6011025492555037`*^9, 3.601102618708476*^9}, {
   3.601102654461521*^9, 3.6011027273706913`*^9}, {3.601102772861294*^9, 
   3.601102846459503*^9}, {3.6011031734732075`*^9, 3.6011032414700966`*^9}, {
   3.601103350439329*^9, 3.601103500101889*^9}, 3.6011035479176245`*^9, {
   3.6011046780122623`*^9, 3.601104719135614*^9}, {3.6011049121456537`*^9, 
   3.601104934323922*^9}, {3.601105130073118*^9, 3.601105169635381*^9}, {
   3.601105218326166*^9, 3.601105238733333*^9}, {3.6011052791466446`*^9, 
   3.60110528518999*^9}, {3.6011060524178734`*^9, 3.601106065839641*^9}, 
   3.6011062830760665`*^9, {3.601106313346798*^9, 3.6011063154039154`*^9}}],

Cell[BoxData[
 DynamicModuleBox[{$CellContext`p0$$ = {0, 1}, $CellContext`p1$$ = {0.5, 
  0.5}, $CellContext`p2$$ = {1, 0}}, 
  RowBox[{"{", 
   RowBox[{
    GraphicsBox[{LocatorBox[Dynamic[$CellContext`p0$$]], 
      LocatorBox[Dynamic[$CellContext`p1$$]], 
      LocatorBox[Dynamic[$CellContext`p2$$]]}], ",", 
    DynamicBox[ToBoxes[
      MatrixForm[{$CellContext`p0$$, $CellContext`p1$$, $CellContext`p2$$}], 
      StandardForm],
     ImageSizeCache->{79., {18., 22.5}}], ",", 
    DynamicBox[ToBoxes[
      $CellContext`correct[
       $CellContext`angle[$CellContext`p0$$, $CellContext`p1$$, \
$CellContext`p2$$]], StandardForm],
     ImageSizeCache->{16., {0., 8.}}]}], "}"}],
  DynamicModuleValues:>{}]], "Output",
 CellChangeTimes->{3.6011052861120434`*^9, 3.601106088603943*^9, 
  3.6011063159849486`*^9}]
}, Open  ]]
},
WindowSize->{1050, 1658},
WindowMargins->{{Automatic, -1058}, {Automatic, -157}},
FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (January 25, 2013)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 94, 1, 31, "Input"],
Cell[CellGroupData[{
Cell[676, 25, 3145, 77, 132, "Input"],
Cell[3824, 104, 817, 19, 197, "Output"]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
